function clearParentData(jspName,jspNo) {
	if(document.getElementById(jspName+":listForm"+jspNo+":formId")!=null){
		var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	}
	if(document.getElementById(jspName+":listForm"+jspNo+":elemId")!=null){
		var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;
	}
	if(document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId")!=null){
		var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;
	}
	if(formId!=null && elemId!=null){
		var instID = document.getElementById(formId + ":" + elemId);
		if(instID!=null){
			instID.value="";
		}
	}
	if(formId!=null && hiddenElemId!=null){
		var hiddenInstID = document.getElementById(formId + ":"+ hiddenElemId);
		if(hiddenInstID!=null){
			hiddenInstID.Value="";
		}
	}
}

//一般的多選(清掉原有的數據)
function updateIDs(jspName,jspNo) {
	
	var debug = false;

	var TableData = document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo);

	var multinomial = document.getElementById(jspName+":listForm"+jspNo+":multinomial");

	// 当限制机构单选时，用户多选后提交前，弹出提示。
	if (multinomial.value == "false") {
		var index = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var checkboxObj = TableData.rows(i).cells(0).children
							.item(0);
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							ymPrompt.errorInfo({title:'操作错误信息',message:'只能选择一个！'});
							return false;
						}
					}
				}
			}
		} else {
			if (TableData != null) {
				for (i = 0; i < TableData.rows.length - 1; i++) {
					var checkboxObj = document
							.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
									+ ":isSelect").checked;
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		}
	}

	// 得到父亲页面
	// var parent = window.opener;
	var strValue = "";
	var strValue1 = "";
	var strCode = "";

	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var checkboxObj = TableData.rows(i).cells(0).children.item(0);
				var hiddenObjCode = TableData.rows(i).cells(0).children.item(1);
				var hiddenObjValue = TableData.rows(i).cells(0).children.item(2);
				var hiddenObjValue1 = TableData.rows(i).cells(0).children.item(3);
//				alert("hiddenObjValue1==="+hiddenObjValue1);
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					strValue = strValue + hiddenObjValue.value + ",";
					if(hiddenObjValue1!=null){
						strValue1 = strValue1 + hiddenObjValue1.value + ",";
//						alert("strValue1==="+strValue1);
					}
					strCode = strCode + hiddenObjCode.value + ",";
					
				}
			}
		}
	} else {
		if (TableData != null) {
			// 			alert("TableData.rows.length="+TableData.rows.length);
			for (i = 0; i < TableData.rows.length - 2; i++) {


				var checkboxObj = document.getElementById("listForm"+jspNo+":listTable"+jspNo+":"
						+ i + ":isSelect");
				var hiddenObjCode = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i + ":hiddenId");
				var hiddenObjValue = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":hiddenName");
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					strValue = strValue + hiddenObjValue.value + ",";
					strCode = strCode + hiddenObjCode.value + ",";
					if(hiddenObjValue1!=null){
						strValue1 = strValue1 + hiddenObjValue1.value + ",";
					}
				}
			}
		}
	}

	if (strValue.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue = strValue.substring(0, strValue.length - 1);
	}
	if (strValue1.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue1 = strValue1.substring(0, strValue1.length - 1);
	}
	if (strCode.length > 0) {
		// 去除代码串末尾多余的“，”
		strCode = strCode.substring(0, strCode.length - 1);
	}

	// 父亲页面存在时修改父亲页面上的值。

	var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	

	var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;

	var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;

	if(hiddenObjValue1!=null){
		var hiddenElemId1 = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId1").value;

		var hiddenInstID1 = document.getElementById(formId + ":"
				+ hiddenElemId1);
		if (hiddenInstID1) {
			hiddenInstID1.value = strValue1;
		}
	}
	
	var instID = document.getElementById(formId + ":" + elemId);

	var hiddenInstID = document.getElementById(formId + ":"
			+ hiddenElemId);
	

	if (instID) {
		instID.value = strValue;
	}
	if (hiddenInstID) {
		hiddenInstID.value = strCode;
	}

	
	if(debug){
	    alert(jspName+":listForm"+jspNo+":listTable"+jspNo);
		alert("TableData===="+TableData);
		alert("multinomial===="+multinomial.value);
		alert("formId===="+formId);
		alert(jspName+":listForm"+jspNo+":elemId"+jspNo);
		alert("elemId===="+elemId);
		alert("hiddenElemId===="+hiddenElemId);
		alert("parent formId : elemId=userMainJSP:"+formId + ":" + elemId);
		alert("parent instID="+instID);
	 	alert("parent formId : hiddenElemId=userMainJSP:"+formId + ":" + hiddenElemId);
		alert("parent hiddenInstID="+hiddenInstID);
		alert("strValue===="+strValue);
		alert("strCode===="+strCode);
		alert(jspName+'Panel'+jspNo);
	}


	index = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				TableData.rows(i).cells(0).children
				.item(0).checked = false;

			}
		}
	} else {
		if (TableData != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":isSelect").checked = false;
			}
		}
	}
	
	if(multinomial.value=="false"){
		Richfaces.hideModalPanel(jspName+'Panel'+jspNo);
	}
}




//追加的多選(不清掉原有的數據，將新數據加在原有數據的後面)
function updateIDAdd(jspName,jspNo) {

	var checkMultinomialInput = false ;
	
	var debug = false;

	var TableData = document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo);

	var multinomial = document.getElementById(jspName+":listForm"+jspNo+":multinomial");

	// 当限制机构单选时，用户多选后提交前，弹出提示。
	if (multinomial.value == "false") {
		var index = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var checkboxObj = TableData.rows(i).cells(0).children
							.item(0);
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		} else {
			if (TableData != null) {
				for (i = 0; i < TableData.rows.length - 1; i++) {
					var checkboxObj = document
							.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
									+ ":isSelect").checked;
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		}
	}

	// 得到父亲页面
	// var parent = window.opener;
	var strValue = "";
	var strCode = "";

	// 父亲页面存在时修改父亲页面上的值。

	var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	

	var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;

	var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;

	var instID = document.getElementById(formId + ":" + elemId);
	

	var hiddenInstID = document.getElementById(formId + ":"
			+ hiddenElemId);

	
	
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取

	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var checkboxObj = TableData.rows(i).cells(0).children.item(0);
				var hiddenObjCode = TableData.rows(i).cells(0).children.item(1);
				var hiddenObjValue = TableData.rows(i).cells(0).children
						.item(2);
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					if(multinomial.value=="true"){
						//判斷是否有重覆選擇
						/*
						alert("instID.value=="+instID.value);
						alert("hiddenObjValue.value=="+hiddenObjValue.value);
						alert("instID.value.length=="+instID.value.length);
						alert("instID.value.indexOf(hiddenObjCode)=="+instID.value.indexOf(hiddenObjValue.value));
						if(instID.value.length == 0){
							strCode = strCode + hiddenObjCode.value + ",";
							strValue = strValue + hiddenObjValue.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else if(instID.value.length > 0 && instID.value.indexOf(hiddenObjValue.value)< 0){
							strCode = strCode + hiddenObjCode.value + ",";
							strValue = strValue + hiddenObjValue.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else{
							//數值重覆，不再新增
						}
						*/
						
						//alert("hiddenInstID.value=="+hiddenInstID.value);
						//alert("hiddenObjCode.value=="+hiddenObjCode.value);
						//alert("hiddenInstID.value.length=="+hiddenInstID.value.length);
						//alert("hiddenInstID.value.indexOf(hiddenObjCode)=="+hiddenInstID.value.indexOf(hiddenObjCode.value));
						if(hiddenInstID.value.length == 0){
							strCode = strCode + hiddenObjCode.value + ",";
							strValue = strValue + hiddenObjValue.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else if(hiddenInstID.value.length > 0 && hiddenInstID.value.indexOf(hiddenObjCode.value)< 0){
							strCode = strCode + hiddenObjCode.value + ",";
							strValue = strValue + hiddenObjValue.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else{
							//數值重覆，不再新增
						}
						

					}else{
						strCode = hiddenObjCode.value + ",";
						strValue = hiddenObjValue.value + ",";
					}

					
				}
			}
		}
	} else {
		if (TableData != null) {
			// 			alert("TableData.rows.length="+TableData.rows.length);
			for (i = 0; i < TableData.rows.length - 2; i++) {


				var checkboxObj = document.getElementById("listForm"+jspNo+":listTable"+jspNo+":"
						+ i + ":isSelect");
				var hiddenObjCode = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i + ":hiddenId");
				var hiddenObjValue = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":hiddenName");
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					strValue = strValue + hiddenObjValue.value + ",";
					strCode = strCode + hiddenObjCode.value + ",";
				}
			}
		}
	}

	if (strValue.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue = strValue.substring(0, strValue.length - 1);
	}
	if (strCode.length > 0) {
		// 去除代码串末尾多余的“，”
		strCode = strCode.substring(0, strCode.length - 1);
	}



	if (instID) {
		if(multinomial.value=="true" && checkMultinomialInput){
			if (instID.value.length>0){
				instID.value = instID.value +","+ strValue;
			}else{
				instID.value = strValue;
			}
		}else if(checkMultinomialInput){
			instID.value = strValue;
		}
	}
	if (hiddenInstID) {
		if(multinomial.value=="true" && checkMultinomialInput){
			if (hiddenInstID.value.length>0){
				hiddenInstID.value = hiddenInstID.value +","+ strCode;
			}else{
				hiddenInstID.value = strCode;
			}
		}else if(checkMultinomialInput){
			hiddenInstID.value = strCode;
		}
	}
	
	if(debug){
	    alert(jspName+":listForm"+jspNo+":listTable"+jspNo);
		alert("TableData===="+TableData);
		alert("multinomial===="+multinomial.value);
		alert("formId===="+formId);
		alert(jspName+":listForm"+jspNo+":elemId"+jspNo);
		alert("elemId===="+elemId);
		alert("hiddenElemId===="+hiddenElemId);
		alert("parent formId : elemId=userMainJSP:"+formId + ":" + elemId);
		alert("parent instID="+instID);
	 	alert("parent formId : hiddenElemId=userMainJSP:"+formId + ":" + hiddenElemId);
		alert("parent hiddenInstID="+hiddenInstID);
		alert("strValue===="+strValue);
		alert("strCode===="+strCode);
		alert(jspName+'Panel'+jspNo);
	}
	
	index = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				TableData.rows(i).cells(0).children
				.item(0).checked = false;

			}
		}
	} else {
		if (TableData != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":isSelect").checked = false;
			}
		}
	}
	

	
}

//商戶一般選擇的多選換行(清掉原有的數據)
function updateIDsMerc(jspName,jspNo) {
	
	var debug = false;

	var TableData = document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo);

	var multinomial = document.getElementById(jspName+":listForm"+jspNo+":multinomial");

	// 当限制机构单选时，用户多选后提交前，弹出提示。
	if (multinomial.value == "false") {
		var index = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var checkboxObj = TableData.rows(i).cells(0).children
							.item(0);
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							ymPrompt.errorInfo({title:'操作错误信息',message:'只能选择一个！'});
							return false;
						}
					}
				}
			}
		} else {
			if (TableData != null) {
				for (i = 0; i < TableData.rows.length - 1; i++) {
					var checkboxObj = document
							.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
									+ ":isSelect").checked;
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		}
	}

	// 得到父亲页面
	// var parent = window.opener;
	var strValue = "";
	var strValue1 = "";
	var strCode = "";
	var strValue2 = "";

	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var checkboxObj = TableData.rows(i).cells(0).children.item(0);
				var hiddenObjCode = TableData.rows(i).cells(0).children.item(1);
				var hiddenObjValue = TableData.rows(i).cells(0).children.item(2);

//				alert("hiddenObjValue1==="+hiddenObjValue1);
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					

					strValue1 = strValue1 + hiddenObjCode.value + "," + hiddenObjValue.value + "\r\n";
					strValue2 = strValue2 + hiddenObjCode.value + ",";
				}
			}
		}
	} 

	if (strValue2.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue2 = strValue2.substring(0, strValue2.length - 1);
	}
	if (strValue1.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue1 = strValue1.substring(0, strValue1.length - 2);
	}
	if (strCode.length > 0) {
		// 去除代码串末尾多余的“，”
		strCode = strCode.substring(0, strCode.length - 2);
	}

	// 父亲页面存在时修改父亲页面上的值。

	var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	

	var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;

	var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;


	
	var instID = document.getElementById(formId + ":" + elemId);

	var hiddenInstID = document.getElementById(formId + ":"
			+ hiddenElemId);
	

	if (instID) {
		instID.value = strValue1;
	}
	if (hiddenInstID) {
		hiddenInstID.value = strValue2;
	}

	
	
	if(debug){
	    alert(jspName+":listForm"+jspNo+":listTable"+jspNo);
		alert("TableData===="+TableData);
		alert("multinomial===="+multinomial.value);
		alert("formId===="+formId);
		alert(jspName+":listForm"+jspNo+":elemId"+jspNo);
		alert("elemId===="+elemId);
		alert("hiddenElemId===="+hiddenElemId);
		alert("parent formId : elemId=userMainJSP:"+formId + ":" + elemId);
		alert("parent instID="+instID);
	 	alert("parent formId : hiddenElemId=userMainJSP:"+formId + ":" + hiddenElemId);
		alert("parent hiddenInstID="+hiddenInstID);
		alert("strValue===="+strValue);
		alert("strCode===="+strCode);
		alert(jspName+'Panel'+jspNo);
	}


	index = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				TableData.rows(i).cells(0).children
				.item(0).checked = false;

			}
		}
	} else {
		if (TableData != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":isSelect").checked = false;
			}
		}
	}
	
	if(multinomial.value=="false"){
		Richfaces.hideModalPanel(jspName+'Panel'+jspNo);
	}
}

//商戶選擇追加換行的多選(不清掉原有的數據，將新數據加在原有數據的後面且要換行，供textarea使用)
function updateIDAddMerc(jspName,jspNo) {

	var checkMultinomialInput = false ;
	
	var debug = false;

	var TableData = document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo);

	var multinomial = document.getElementById(jspName+":listForm"+jspNo+":multinomial");

	// 当限制机构单选时，用户多选后提交前，弹出提示。
	if (multinomial.value == "false") {
		var index = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var checkboxObj = TableData.rows(i).cells(0).children
							.item(0);
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		} else {
			if (TableData != null) {
				for (i = 0; i < TableData.rows.length - 1; i++) {
					var checkboxObj = document
							.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
									+ ":isSelect").checked;
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		}
	}

	// 得到父亲页面
	// var parent = window.opener;
	var strValue = "";
	var strCode = "";
	var strValue1 = "";
	var strValue2 = "";
	// 父亲页面存在时修改父亲页面上的值。

	var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	

	var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;

	var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;

	var instID = document.getElementById(formId + ":" + elemId);
	

	var hiddenInstID = document.getElementById(formId + ":"
			+ hiddenElemId);

	
	
	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取

	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var checkboxObj = TableData.rows(i).cells(0).children.item(0);
				var hiddenObjCode = TableData.rows(i).cells(0).children.item(1);
				var hiddenObjValue = TableData.rows(i).cells(0).children
						.item(2);
				var isChecked = checkboxObj.checked;

				if (isChecked) {
					// 选中的代码处理
					if(multinomial.value=="true"){
						//判斷是否有重覆選擇

						if(instID.value.length == 0){
							strValue1 = strValue1 + hiddenObjCode.value + "," + hiddenObjValue.value + "\r\n";
							strValue2 = strValue2 + hiddenObjCode.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else if(instID.value.length > 0 && instID.value.indexOf(hiddenObjCode.value)< 0){

							strValue1 = strValue1 + hiddenObjCode.value + "," + hiddenObjValue.value + "\r\n";
							strValue2 = strValue2 + hiddenObjCode.value + ",";
							checkMultinomialInput = true ; //表示值無重覆
						}else{
							//數值重覆，不再新增
						}
						

					}

					
				}
			}

		}
	} 
	
	if (strValue1.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue1 = strValue1.substring(0, strValue1.length - 2);
	}
	if (strValue2.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue2 = strValue2.substring(0, strValue2.length - 1);
	}



	if (instID) {
		if(multinomial.value=="true" && checkMultinomialInput){
			if (instID.value.length>0){
				instID.value = instID.value +"\r\n"+ strValue1;
			}else{
				instID.value = strValue1;
			}
		}else if(checkMultinomialInput){
			instID.value = strValue1;
		}
	}
	if (hiddenInstID) {
		if(multinomial.value=="true" && checkMultinomialInput){
			if (hiddenInstID.value.length>0){
				hiddenInstID.value = hiddenInstID.value +","+ strValue2;
			}else{
				hiddenInstID.value = strValue2;
			}
		}else if(checkMultinomialInput){
			hiddenInstID.value = strValue2;
		}
	}
	
	if(debug){
	    alert(jspName+":listForm"+jspNo+":listTable"+jspNo);
		alert("TableData===="+TableData);
		alert("multinomial===="+multinomial.value);
		alert("formId===="+formId);
		alert(jspName+":listForm"+jspNo+":elemId"+jspNo);
		alert("elemId===="+elemId);
		alert("hiddenElemId===="+hiddenElemId);
		alert("parent formId : elemId=userMainJSP:"+formId + ":" + elemId);
		alert("parent instID="+instID);
	 	alert("parent formId : hiddenElemId=userMainJSP:"+formId + ":" + hiddenElemId);
		alert("parent hiddenInstID="+hiddenInstID);
		alert("strValue===="+strValue);
		alert("strCode===="+strCode);
		alert(jspName+'Panel'+jspNo);
	}
	
	index = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				TableData.rows(i).cells(0).children
				.item(0).checked = false;

			}
		}
	} else {
		if (TableData != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":isSelect").checked = false;
			}
		}
	}
	

	
}

//供人員選擇用的機構選擇(清掉原有的數據)
function updateIDsPers(parentjsp,jspName,jspNo) {
	
	//alert(document.getElementById("persSelect001:persSelectForm001"));
	
	var debug = false;

	var TableData = document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo);

	var multinomial = document.getElementById(jspName+":listForm"+jspNo+":multinomial");

	// 当限制机构单选时，用户多选后提交前，弹出提示。
	if (multinomial.value == "false") {
		var index = 0;
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			if (TableData != null) {
				for (i = 1; i < TableData.rows.length - 1; i++) {
					var checkboxObj = TableData.rows(i).cells(0).children
							.item(0);
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							ymPrompt.errorInfo({title:'操作错误信息',message:'只能选择一个！'});
							return false;
						}
					}
				}
			}
		} else {
			if (TableData != null) {
				for (i = 0; i < TableData.rows.length - 1; i++) {
					var checkboxObj = document
							.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
									+ ":isSelect").checked;
					var isChecked = checkboxObj.checked;
					if (isChecked) {
						index++;
						if (index > 1) {
							alert("只能选择一个！");
							return false;
						}
					}
				}
			}
		}
	}

	// 得到父亲页面
	// var parent = window.opener;
	var strValue = "";
	var strValue1 = "";
	var strCode = "";

	// 判断浏览器类型，如果是IE则使用table表格获取，否则通过ID获取
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				var checkboxObj = TableData.rows(i).cells(0).children.item(0);
				var hiddenObjCode = TableData.rows(i).cells(0).children.item(1);
				var hiddenObjValue = TableData.rows(i).cells(0).children.item(2);
				var hiddenObjValue1 = TableData.rows(i).cells(0).children.item(3);
//				alert("hiddenObjValue1==="+hiddenObjValue1);
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					strValue = strValue + hiddenObjValue.value + ",";
					if(hiddenObjValue1!=null){
						strValue1 = strValue1 + hiddenObjValue1.value + ",";
//						alert("strValue1==="+strValue1);
					}
					strCode = strCode + hiddenObjCode.value + ",";
					
				}
			}
		}
	} else {
		if (TableData != null) {
			// 			alert("TableData.rows.length="+TableData.rows.length);
			for (i = 0; i < TableData.rows.length - 2; i++) {


				var checkboxObj = document.getElementById("listForm"+jspNo+":listTable"+jspNo+":"
						+ i + ":isSelect");
				var hiddenObjCode = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i + ":hiddenId");
				var hiddenObjValue = document
						.getElementById("listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":hiddenName");
				var isChecked = checkboxObj.checked;
				if (isChecked) {
					// 选中的代码处理
					strValue = strValue + hiddenObjValue.value + ",";
					strCode = strCode + hiddenObjCode.value + ",";
					if(hiddenObjValue1!=null){
						strValue1 = strValue1 + hiddenObjValue1.value + ",";
					}
				}
			}
		}
	}

	if (strValue.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue = strValue.substring(0, strValue.length - 1);
	}
	if (strValue1.length > 0) {
		// 去除代码串末尾多余的“，”
		strValue1 = strValue1.substring(0, strValue1.length - 1);
	}
	if (strCode.length > 0) {
		// 去除代码串末尾多余的“，”
		strCode = strCode.substring(0, strCode.length - 1);
	}

	// 父亲页面存在时修改父亲页面上的值。

	var formId = document.getElementById(jspName+":listForm"+jspNo+":formId").value;
	

	var elemId = document.getElementById(jspName+":listForm"+jspNo+":elemId").value;

	var hiddenElemId = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId").value;

	if(hiddenObjValue1!=null){
		var hiddenElemId1 = document.getElementById(jspName+":listForm"+jspNo+":hiddenElemId1").value;

		var hiddenInstID1 = document.getElementById(formId + ":"
				+ hiddenElemId1);
		if (hiddenInstID1) {
			hiddenInstID1.value = strValue1;
		}
	}
	
	var instID = document.getElementById(parentjsp+":"+formId + ":" + elemId);

	var hiddenInstID = document.getElementById(parentjsp+":"+formId + ":"
			+ hiddenElemId);
	

	if (instID) {
		instID.value = strValue;
	}
	if (hiddenInstID) {
		hiddenInstID.value = strCode;
	}

	
	if(debug){
	    alert(jspName+":listForm"+jspNo+":listTable"+jspNo);
		alert("TableData===="+TableData);
		alert("multinomial===="+multinomial.value);
		alert("formId===="+formId);
		alert(jspName+":listForm"+jspNo+":elemId"+jspNo);
		alert("elemId===="+elemId);
		alert("hiddenElemId===="+hiddenElemId);
		alert("parent formId : elemId=userMainJSP:"+formId + ":" + elemId);
		alert("parent instID="+instID);
	 	alert("parent formId : hiddenElemId=userMainJSP:"+formId + ":" + hiddenElemId);
		alert("parent hiddenInstID="+hiddenInstID);
		alert("strValue===="+strValue);
		alert("strCode===="+strCode);
		alert(jspName+'Panel'+jspNo);
	}


	index = 0;
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (TableData != null) {
			for (i = 1; i < TableData.rows.length - 1; i++) {
				TableData.rows(i).cells(0).children
				.item(0).checked = false;

			}
		}
	} else {
		if (TableData != null) {
			for (i = 0; i < TableData.rows.length - 1; i++) {
				document.getElementById(jspName+":listForm"+jspNo+":listTable"+jspNo+":" + i
								+ ":isSelect").checked = false;
			}
		}
	}
	
	if(multinomial.value=="false"){
		Richfaces.hideModalPanel(jspName+'Panel'+jspNo);
	}
}

Richfaces.showModalPanel = function (id, opts, event) {
	var panel = $(id);
	if (!panel) {
		panel = Richfaces.findModalPanel(id);
	}
	panel.component.show(event, opts);

};
